package com.midele.goodstuff.ui.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

@Composable
fun RoundedCornerTextField(
    value: String,
    onValueChange: (String) -> Unit,
    modifier: Modifier = Modifier,
    label: String = "",
    cornerRadius: Dp = 100.dp  // 设置圆角大小
) {
    Box(
        modifier = modifier
            .background(Color.Black, RoundedCornerShape(cornerRadius)) // 设置黑色背景和圆角
            .padding(vertical = 8.dp, horizontal = 12.dp) // 设置内边距
    ) {
        TextField(
            value = value,
            onValueChange = onValueChange,
            colors = TextFieldDefaults.colors(
                focusedIndicatorColor = Color.Transparent, // 移除焦点指示器颜色
                unfocusedIndicatorColor = Color.Transparent // 移除非焦点指示器颜色
            ),
            modifier = Modifier.fillMaxWidth(), // 使TextField充满整个Box的宽度
            label = { Text(text = label) } // 添加label（可选）
        )
    }
}